return ret;
}
+/**
+ * ostree_repo_prune:
+ * @self: Repo
+ * @flags: Options controlling prune process
+ * @depth: Stop traversal after this many iterations (-1 for unlimited)
+ * @out_objects_total: (out): Number of objects found
+ * @out_objects_pruned: (out): Number of objects deleted
+ * @out_pruned_object_size_total: (out): Storage size in bytes of objects deleted
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Delete content from the repository. By default, this function will
+ * only delete "orphaned" objects not referred to by any commit. This
+ * can happen during a local commit operation, when we have written
+ * content objects but not saved the commit referencing them.
+ *
+ * However, if %OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY is provided, instead
+ * of traversing all commits, only refs will be used. Particularly
+ * when combined with @depth, this is a convenient way to delete
+ * history from the repository.
+ *
+ * Use the %OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE to just determine
+ * statistics on objects that would be deleted, without actually
+ * deleting them.
+ */
gboolean
-ostree_repo_prune (OstreeRepo *repo,
+ostree_repo_prune (OstreeRepo *self,
OstreeRepoPruneFlags flags,
gint depth,
gint *out_objects_total,
OtPruneData data = { 0, };
gboolean refs_only = flags & OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
- data.repo = repo;
+ data.repo = self;
data.reachable = ostree_repo_traverse_new_reachable ();
if (refs_only)
{
- if (!ostree_repo_list_refs (repo, NULL, &all_refs,
+ if (!ostree_repo_list_refs (self, NULL, &all_refs,
cancellable, error))
goto out;
{
const char *checksum = value;
- if (!ostree_repo_traverse_commit (repo, checksum, depth, data.reachable,
+ if (!ostree_repo_traverse_commit (self, checksum, depth, data.reachable,
cancellable, error))
goto out;
}
}
- if (!ostree_repo_list_objects (repo, OSTREE_REPO_LIST_OBJECTS_ALL, &objects,
+ if (!ostree_repo_list_objects (self, OSTREE_REPO_LIST_OBJECTS_ALL, &objects,
cancellable, error))
goto out;
if (objtype != OSTREE_OBJECT_TYPE_COMMIT)
continue;
- if (!ostree_repo_traverse_commit (repo, checksum, depth, data.reachable,
+ if (!ostree_repo_traverse_commit (self, checksum, depth, data.reachable,
cancellable, error))
goto out;
}
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
- * Copyright (C) 2011 Colin Walters <walters@verbum.org>
+ * Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
- *
- * Author: Colin Walters <walters@verbum.org>
*/
#include "config.h"
return ret;
}
+/**
+ * ostree_repo_list_refs:
+ * @self: Repo
+ * @refspec_prefix: (allow-none): Only list refs which match this prefix
+ * @out_all_refs: (out) (element-type utf8 utf8): Mapping from ref to checksum
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * If @refspec_prefix is %NULL, list all local and remote refspecs,
+ * with their current values in @out_all_refs. Otherwise, only list
+ * refspecs which have @refspec_prefix as a prefix.
+ */
gboolean
-ostree_repo_list_refs (OstreeRepo *repo,
+ostree_repo_list_refs (OstreeRepo *self,
const char *refspec_prefix,
GHashTable **out_all_refs,
GCancellable *cancellable,
goto out;
if (remote)
- dir = g_file_get_child (repo->remote_heads_dir, remote);
+ dir = g_file_get_child (self->remote_heads_dir, remote);
else
- dir = g_object_ref (repo->local_heads_dir);
+ dir = g_object_ref (self->local_heads_dir);
child = g_file_resolve_relative_path (dir, ref_prefix);
if (!ot_gfile_query_info_allow_noent (child, OSTREE_GIO_FAST_QUERYINFO, 0,
{
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
{
- if (!enumerate_refs_recurse (repo, remote, child, child,
+ if (!enumerate_refs_recurse (self, remote, child, child,
ret_all_refs,
cancellable, error))
goto out;
{
gs_unref_object GFileEnumerator *remote_enumerator = NULL;
- if (!enumerate_refs_recurse (repo, NULL, repo->local_heads_dir, repo->local_heads_dir,
+ if (!enumerate_refs_recurse (self, NULL, self->local_heads_dir, self->local_heads_dir,
ret_all_refs,
cancellable, error))
goto out;
- remote_enumerator = g_file_enumerate_children (repo->remote_heads_dir, OSTREE_GIO_FAST_QUERYINFO,
+ remote_enumerator = g_file_enumerate_children (self->remote_heads_dir, OSTREE_GIO_FAST_QUERYINFO,
0,
cancellable, error);
break;
name = g_file_info_get_name (info);
- if (!enumerate_refs_recurse (repo, name, child, child,
+ if (!enumerate_refs_recurse (self, name, child, child,
ret_all_refs,
cancellable, error))
goto out;
return ret;
}
+/**
+ * ostree_repo_write_ref:
+ * @self: Repo
+ * @remote: (allow-none): Optional remote name
+ * @name: Name of ref, e.g. foo/bar/baz
+ * @rev: (allow-none); ASCII SHA256 checksum; if %NULL, then delete @name
+ * @error: Error
+ *
+ * If @rev is not %NULL, then it as the target of ref named @name; if
+ * @remote is provided, the ref will appear originate from that
+ * remote.
+ *
+ * Otherwise, if @rev is %NULL, then delete the ref @name if it exists.
+ *
+ * This function merely changes the ref target; it is possible to use
+ * it to target earlier commits.
+ */
gboolean
ostree_repo_write_ref (OstreeRepo *self,
const char *remote,
return ret;
}
+/**
+ * ostree_repo_write_refspec:
+ * @self: Repo
+ * @refspec: Optional remote with name of ref, e.g. remotename:foo/bar/baz
+ * @rev: (allow-none); ASCII SHA256 checksum; if %NULL, then delete @refspec
+ * @error: Error
+ *
+ * Like ostree_repo_write_ref(), but takes concatenated @refspec
+ * format as input instead of separate remote and name arguments.
+ */
gboolean
ostree_repo_write_refspec (OstreeRepo *self,
const char *refspec,